/*
 * ========================================================
 * Copyright(c) 2014 杭州偶尔科技-版权所有
 * ========================================================
 * 本软件由杭州偶尔科技所有, 未经书面许可, 任何单位和个人不得以
 * 任何形式复制代码的部分或全部, 并以任何形式传播。
 * 公司网址
 *
 * 			http://www.kkkd.com/
 *
 * ========================================================
 */
package com.simon.mengkou.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.facebook.drawee.view.SimpleDraweeView;
import com.simon.mengkou.R;
import com.simon.mengkou.data.bean.base.Activity;
import com.simon.mengkou.data.bean.base.Follow;
import com.simon.mengkou.data.bean.base.GoodTopic;
import com.simon.mengkou.data.bean.base.Topic;
import com.simon.mengkou.data.bean.base.User;
import com.simon.mengkou.system.global.OuerApplication;
import com.simon.mengkou.system.global.OuerDispatcher;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author : Zhenshui.Xia
 * @since : 2016/3/23.
 * desc    : 商品专题适配器
 */
public class GoodsTopicAdapter extends AbsAdapter<GoodTopic> {

    public GoodsTopicAdapter(Context context, List<GoodTopic> datas) {
        super(context);
        mList = datas;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        final Holder holder;
        if (null == convertView) {
            convertView = mInflater.inflate(R.layout.layout_goods_topic_image_item, null);
            holder = new Holder();
            convertView.setTag(holder);
            ButterKnife.bind(holder, convertView);
        } else {
            holder = (Holder) convertView.getTag();
        }

        final GoodTopic data = getItem(position);

        OuerApplication.mImageLoader.loadImage(holder.mSdvImage, data.getImage().getUrl());
        holder.mSdvImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //打开商品专题
                OuerDispatcher.presentGoodsTopicActivity(mContext, data.getId(), data.getImage().getUrl());
            }
        });


        return convertView;
    }


    /**
     * @author zhenshui.xia
     */
    class Holder {
        //头像
        @Bind(R.id.image_id_image)
        SimpleDraweeView mSdvImage;

    }
}
